/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    page: { type: 'string' },
    table: { type: 'string' },
    describe: { type: 'string' },
    isEnabled: { type: 'boolean' },
    searchUsed: { type: 'boolean' },
    tableUsed: { type: 'boolean' },
    detailUsed: { type: 'boolean' },
    required: { type: 'boolean' },
    title: { type: 'string' },
    label: { type: 'string' },
    key: { type: 'string' },
    defaultValue: { type: 'object' },
    enableArea: { type: 'array' },
    inputType: { type: 'string' },
    type: { type: 'string' },
    selectOption: { type: 'array' },
    url: { type: 'object' },
    isCode: { type: 'boolean' },
    isInitKey: { type: 'boolean' },
    /**
     * 是否为唯一编码
     */
    isUnique: { type: 'boolean' }
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('DLabel', _schema);
};
